package br.com.exemplo.vendas.negocio.dao ;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;

import br.com.exemplo.vendas.negocio.entity.Item;

public class ItemDAO extends GenericDAO<Item>
{
	public ItemDAO( EntityManager em )
	{
		super( em ) ;
	}

	public ItemDAO( )
	{
		super( Persistence.createEntityManagerFactory( "Vendas" ).createEntityManager( ) ) ;
	}

	@SuppressWarnings("unchecked")
	public List<Item> listarItens()
	{
		List<Item> obj = new ArrayList<Item>() ;

		try
		{
			Query query = em.createQuery( "from Item where reserva != null" ) ;
			obj = (List<Item>)query.getResultList();
		}
		catch (Exception e)
		{
			if (debugInfo)
			{
				e.printStackTrace( ) ;
			}
		}
		return obj ;
	}

}